<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="new :: common_head('所有设备')">
    <style>
        .changeI{
            display: block;
            width: 100%;
            height: 100%;
        }
        ul li{
            list-style: none;
            margin: 0;
            padding: 0;
        }
        .navbar .nav > li > .dropdown-menu::before {
            display: none!important;
        }
        .navbar .nav > li > .dropdown-menu::after {
            display: none !important;
        }
        .dropdown-menu:hover, .dropdown-menu:hover{
            display: none !important;
        }
        .dropdown-menu:hover::before, .dropdown-menu:hover::after{
            display: none !important;
        }
        #myli >ul:hover::before{
            display: none;
        }
    </style>
</head>

<body>
<!--删除提示模态框-->
<div class="modal fade" id="delcfmModel1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel">提示</h4>
            </div>
            <div class="modal-body">是否要删除？</div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" onclick="deleteEdgeById()">确定</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<!--删除提示模态框结束-->
<!-- start: Header -->
<div th:replace="~{new::header}"></div>
<!-- start: Header -->

<div class="container-fluid-full">
    <div class="row-fluid">

        <!-- start: Main Menu -->
        <div id="sidebar-left" class="span2" th:replace="new::sidebar_left"></div>
        <!-- end: Main Menu -->

        <noscript>
            <div class="alert alert-block span10">
                <h4 class="alert-heading">Warning!</h4>
                <p>You need to have <a href="" target="_blank">JavaScript</a> enabled to use this site.</p>
            </div>
        </noscript>

        <!-- start: Content -->
        <div id="content" class="span10">


            <ul class="breadcrumb">
                <li>
                    <i class="icon-home"></i>
                    <a th:href="@{/new.html}">主页</a>
                    <i class="icon-angle-right"></i>
                </li>
                <li><a href="#">设备展示</a></li>
            </ul>

            <div class="row-fluid sortable">
                <div class="box span12">
                    <div class="box-header" data-original-title>
                        <h2><i class="halflings-icon white user"></i><span class="break"></span>设备展示</h2>
                        <div class="box-icon">

                        </div>
                    </div>
                    <div class="box-content">
                        <div class="container" style="margin-left: 0px">
                            <ul id="mytab" class="nav nav-pills nav-justified">
                                <li role="presentation" class="dropdown" id="myli"><a href="#" class="dropdown-toggle"
                                                                                      data-toggle="dropdown">添加基础策略
                                    <span class="caret"></span></a>
                                    <ul class="dropdown-menu" >
                                        <li th:each="graph,graphStat:${graphInfoList}" ><a th:href="@{/relationship/add/}+${graph.graphId}" th:text="${graph.graphName}"></a></li>
                                    </ul>
                                </li>
                            </ul>
                        </div>
                        <div  class="container" style="margin-left:0px"><!-- 跳转开始 -->
                            <ul id="mytab1" class="nav nav-pills nav-justified" role="tablist">
                                <li  th:each="graph,graphStat:${graphInfoList}" th:class="${graphStat.index}==0?'active':''" role="presentation" th:id="'li'+${graph.graphId}"><a th:href="@{/relationship/viewRelationship/}+${graph.graphId}" th:text="${graph.graphName}"></a></li>
                            </ul>
                        </div><!-- 跳转结束 -->
                        <table class="table table-striped table-bordered bootstrap-datatable datatable">
                            <thead>
                            <tr>
                                <th>基础策略ID</th>
                                <th>源设备名</th>
                                <th>目标设备名</th>
                                <th>损耗率</th>
                                <th>能源属性</th>
                                <th>所属图谱</th>
                                <th>是否可共用</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr th:each="relationEdge:${relationshipList}">
                                <td th:text="${relationEdge.id}"></td>
                                <td class="center" th:text="${relationEdge.deviceFromName}"></td>
                                <td class="center" th:text="${relationEdge.deviceToName}"></td>
                                <td class="center" th:text="${relationEdge.lossRate}"></td>
                                <td class="center" th:text="${relationEdge.typeName}"></td>
                                <td class="center" th:text="${relationEdge.graphName}"></td>
                                <td class="center" th:text="${relationEdge.isShard}==1?'是':'否'"></td>
                                <td class="center">
                                    <!-- 查看字体图标开始-->
                                    <!--<a class="btn btn-success" title="查看" th:href="@{/device/getDeviceInfo/}+${device.deviceId}">-->
                                        <!--<i class="halflings-icon white zoom-in"></i>-->
                                    <!--</a>-->
                                    <!-- 修改字体图标结束-->
                                    <!--<a class="btn btn-info" title="修改" th:href="@{/device/get/}+${device.deviceId}">-->
                                        <!--<i class="halflings-icon white edit"></i>-->
                                    <!--</a>-->
                                    <a class="btn btn-info" title="修改" th:href="@{/relationship/get/}+${relationEdge.id}" >
                                        <i class="halflings-icon white edit" ></i>
                                    </a>
                                    <!--<a  class="btn btn-danger" >-->
                                    <!--<i th:id="${device.deviceId}" class="halflings-icon white trash changeI"  onclick="deleteDevice()"></i>-->
                                    <!--</a>-->
                                    <!--<a  class="btn btn-danger" href="#" title="删除" th:id="${device.deviceId}" onclick="deleteDevice()">-->
                                        <!--删除-->
                                    <!--</a>-->
                                    <a  class="btn btn-danger" href="#" title="删除" th:id="${relationEdge.id}" onclick="deleteEdge()">
                                        删除
                                    </a>
                                </td>
                            </tr>
                            </tbody>

                        </table>
                    </div>
                </div>
            </div>
        </div><!--/.fluid-container-->
        <!-- end: Content -->
    </div><!--/#content.span10-->
</div><!--/fluid-row-->

<div class="modal hide fade" id="myModal">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
        <h3>Settings</h3>
    </div>
    <div class="modal-body">
        <p>Here settings can be configured...</p>
    </div>
    <div class="modal-footer">
        <a href="#" class="btn" data-dismiss="modal">Close</a>
        <a href="#" class="btn btn-primary">Save changes</a>
    </div>
</div>
<div class="common-modal modal fade" id="common-Modal1" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-content">
        <ul class="list-inline item-details">
            <li><a href="http://sc.chinaz.com">Admin templates</a></li>
            <li><a href="http://sc.chinaz.com">Bootstrap themes</a></li>
        </ul>
    </div>
</div>
<div class="clearfix"></div>


<div th:replace="new::common_js"></div>
<script>
   // 获取当前点击的设备菜单，添加高亮显示
   var deleteEdgeId="";
    $(document).ready(function () {
        var location=window.location.href;//获取网页地址
        var id=location.substring(location.lastIndexOf('/')+1);//获取/后的id
        $("#"+"li"+id).addClass("active").siblings().removeClass("active");//对应li高亮
    })

    //删除边，弹出模态框提示
   function deleteEdge() {
       $("#delcfmModel1").modal("show");
       deleteEdgeId=$(event.target).attr("id");
       console.log(deleteEdgeId);

   }
   //模态框确认删除
   function deleteEdgeById(){
           $.ajax({
               type: "GET",
               url: "/power/relationship/delete/" + deleteEdgeId,
               success: function () {
                   $("#delcfmModel1").modal("hide"); //模态框隐藏
                   location.reload();
               }
           })
   }
</script>
</body>
</html>
